<template>
  <div>
    <div class="ggfl_tk">
      <div class="ggfl_box">
        <h2>{{$parent.edittit}}广告分类</h2>
        <div class="close" @click="close">
          <a-icon type="close" />
        </div>
        <ul>
          <!-- <li>
                  <span class="inp_tit"> <span class="red">*</span> ID：</span>
                  <a-input placeholder='请输入ID'/>
          </li>-->
          <li>
            <span class="inp_tit">
              <span class="red">*</span> 广告编号：
            </span>
            <a-input style="width:300px;" v-model="number" placeholder="请输入编号" />
          </li>
          <li>
            <span class="inp_tit">
              <span class="red">*</span> 分类描述：
            </span>
            <a-input v-model="describe" placeholder="请输入名称" />
          </li>
          <li class="sub_li">
            <a-button @click="close">取消</a-button>
            <a-button type="primary" @click="adclassAdd">提交</a-button>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
export default {
  data() {
    return {
      number: "",
      describe: "",
      id_num: ""
    };
  },

  methods: {
    adclassAdd() {
      if (this.$parent.edittit == "新增") {
        this.axios
          .post(
            "suggest/adclassAdd.php",
            qs.stringify({
              number: this.number,
              describe: this.describe
            })
          )
          .then(res => {
            console.log(res);
            if (res.data.code == 303) {
              this.$notification["success"]({
                message: "成功",
                description: res.data.msg
              });
              this.$parent.gg_flag = false;
              this.$parent.getadclassList();
            } else {
              this.$notification["error"]({
                message: "失败",
                description: res.data.msg
              });
            }
          });
      } else {
        this.axios
          .post(
            "suggest/adclassEdit.php",
            qs.stringify({
              id_num: this.id_num,
              number: this.number,
              describe: this.describe
            })
          )
          .then(res => {
            console.log(res);
            if (res.data.code == 303) {
              this.$notification["success"]({
                message: "成功",
                description: res.data.msg
              });
              this.$parent.gg_flag = false;
              this.$parent.getadclassList(this.$parent.pagination);
            } else {
              this.$notification["error"]({
                message: "失败",
                description: res.data.msg
              });
            }
          });
      }
    },

    close() {
      this.$parent.gg_flag = false;
    },
 
  },

  created() {
    if (this.$parent.edittit == "修改") {
      this.number = this.$parent.editval.number;
      this.describe = this.$parent.editval.describe;
      this.id_num = this.$parent.editval.id_num;
    } else {
    }
  }
};
</script>

<style lang='less'>
.ggfl_tk {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 1000px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  text-align: left;
  .ggfl_box {
    position: absolute;
    top: 30%;
    left: 50%;
    width: 37%;
    background: #fff;
    transform: translate(-50%, -50%);
    padding: 20px 30px;
    h2 {
      font-weight: bold;
      margin-bottom: 20px;
    }
    ul {
      li {
        margin: 20px 0;
        .inp_tit {
          width: 100px;
          text-align: right;
          display: inline-block;
          .red {
            color: red;
          }
        }
        input {
          width: 300px;
        }
      }
      .sub_li {
        text-align: center;
        button {
          margin: 0 10px;
        }
      }
    }
  }
}
</style>
